﻿using AnQinFrameWorkAPI.Entity.SystemCore.DTO.RoleButton;
using AnQinFrameWorkAPI.Entity.SystemCore.View.RoleButton;
using AnQinFrameWorkAPI.Service.SystemCore;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.SystemCore;

/// <summary>
///     角色按钮API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "SystemCore")]
public class RoleButtonController : ControllerBase
{
    //业务接口
    private readonly RoleButtonService _roleButtonService;

    //构造注入
    public RoleButtonController(RoleButtonService roleButtonService)
    {
        _roleButtonService = roleButtonService;
    }

    /// <summary>
    ///     获取角色按钮列表
    /// </summary>
    [ProducesResponseType(typeof(RoleButtonView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetRoleMenuList([FromQuery] RoleButtonSearchDTO roleButtonSearchDto)
    {
        var response = await _roleButtonService.GetRoleButtonList(roleButtonSearchDto);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     启用角色按钮
    /// </summary>
    [HttpPost("EnableMulti")]
    public async Task<IActionResult> EnableRoleMenu([FromBody] RoleButtonUpdateDTO roleMenuUpdateDto)
    {
        var response = await _roleButtonService.EnableMultiRoleButton(roleMenuUpdateDto);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     禁用角色按钮
    /// </summary>
    [HttpPost("DisableMulti")]
    public async Task<IActionResult> DisableRoleMenu([FromBody] RoleButtonUpdateDTO roleMenuUpdateDto)
    {
        var response = await _roleButtonService.DisableMultiRoleButton(roleMenuUpdateDto);
        return StatusCode(response.Status, response);
    }
}